package pers.jphoebe.quartz.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import pers.jphoebe.quartz.dao.mysql.VarietyMapper;
import pers.jphoebe.quartz.entity.Variety;
import pers.jphoebe.quartz.entity.response.ErrorCode;
import pers.jphoebe.quartz.entity.response.ResponseData;
import pers.jphoebe.quartz.exception.CustomException;
import pers.jphoebe.quartz.service.VarietyService;
import pers.jphoebe.quartz.utils.Logger;
import pers.jphoebe.quartz.utils.ResponseDataUtils;

/**
 * Created by 蒋时华 on 2017/11/1.
 */
@Service
public class VarietyServiceImpl implements VarietyService {

    private Logger logger = Logger.getLogger(this.getClass());
    @Autowired
    private VarietyMapper varietyMapper;

    @Override
    public ResponseData<Integer> saveVariety(Variety variety) throws CustomException{
        try {
            return ResponseDataUtils.success(varietyMapper.saveVariety(variety));
        }catch (Exception e){
            logger.error(e);
            throw new CustomException(ErrorCode.ERROR_SAVE_VARIETY);
        }
    }
}
